package com.seashop.controller;

import com.seashop.response.ResponseBase;
import com.seashop.feign.UserFeignClient;
import com.seashop.request.LoginRequestParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author moredln
 * @desc
 * @date 2020-08-06 17:54
 */
@RestController
@Api(tags = "用户模块——聚合接口")
public class UserController {

    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping("/user/getVerificationCode")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "电话号码", name = "mobile", dataType = "string", required = true),
            @ApiImplicitParam(value = "地区编码(66:泰国;62:印尼;86:中国;1:美国;03:巴基斯坦;)", name = "areaCode", dataType = "string", required = true),
            @ApiImplicitParam(value = "国家编码(TH:泰国;IN:印尼;ZH:中国;US:美国;UR:巴基斯坦;)", name = "countryCode", dataType = "string", required = true)
    })
    @ApiOperation(value = "获取手机验证码")
    public ResponseBase getVerificationCode(String mobile, String areaCode, String countryCode) {
        return userFeignClient.getVerificationCode(mobile, areaCode, countryCode);
    }

    @PostMapping("/user/loginOrRegister")
    @ApiOperation(value = "登陆注册")
    public ResponseBase loginOrRegister(@RequestBody LoginRequestParam param) {
        return userFeignClient.loginOrRegister(param);
    }

    @GetMapping("/user/queryMemberLevel")
    @ApiOperation(value = "查询会员等级")
    @ApiImplicitParam(value = "用户ID", name = "userId", dataType = "integer", required = true)
    public ResponseBase queryMemberLevel(Integer userId){
        return userFeignClient.queryMemberLevel(userId);
    }
}
